import axios from '@/utils/axios'
// 获取文章列表
export const getArticleList = (params) => {
  return axios({
    url: '/mp/v1_0/articles',
    method: 'GET',
    params
  })
}
// 获取频道
export const getChannelList = () => {
  return axios.get('/mp/v1_0/channels')
}
// 删除文章
export const delArticle = (id) => {
  return axios.delete(`/mp/v1_0/articles/${id}`)
}
// 新增文章
export const postAddArticle = (draft, data) => {
  return axios({
    url: '/mp/v1_0/articles',
    method: 'POST',
    params: {
      draft
    },
    data
  })
}
// 根据id获取对应id的文章信息
export const getOneArticle = (id) => {
  return axios.get(`/mp/v1_0/articles/${id}`)
}
// 修改文章信息
export const editArticle = (id, draft, data) => {
  return axios({
    url: `/mp/v1_0/articles/${id}`,
    method: 'PUT',
    params: {
      draft
    },
    data
  })
}
// 更新文章的评论状态
export const updateStatus = (id, status) => {
  return axios({
    url: '/mp/v1_0/comments/status',
    method: 'PUT',
    params: {
      article_id: id
    },
    data: {
      allow_comment: status
    }
  })
}
